<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page import="Unit2.controller.TestControllerForWeb" %>
<%@ page import="Unit2.question.QuesionTypes.Question" %>
<%@ page contentType="text/html;charset=windows-1251" language="java" %>
<%!TestControllerForWeb controllerForWeb;
    Question currentQuestion;%>
<% controllerForWeb=(TestControllerForWeb)session.getAttribute("Controller");
    currentQuestion =controllerForWeb.questionList.getQuestion(controllerForWeb.getGlobalIndex());%>

<html>
<head>
    <title></title>
</head>
<body>




    <%   if (request.getParameterValues("variant")!=null&&request.getParameter("answer")!=null){
    String [] answersArray=request.getParameterValues("variant");


    controllerForWeb.ask(answersArray);
    currentQuestion=controllerForWeb.questionList.getQuestion(controllerForWeb.getGlobalIndex());
    if (!controllerForWeb.continueAsking()){
        controllerForWeb.saveHistory();
        response.sendRedirect("final.jsp");
        return;
    }
    }
    if (request.getParameter("skip")!=null) {

        controllerForWeb.skip=true;
        controllerForWeb.undo=false;
        controllerForWeb.ask(new String[]{""});
       currentQuestion=controllerForWeb.questionList.getQuestion(controllerForWeb.getGlobalIndex());
    }
    if (request.getParameter("undo")!=null) {

        controllerForWeb.undo=true;
        controllerForWeb.skip=false;
        controllerForWeb.ask(new String[]{""});
        currentQuestion=controllerForWeb.questionList.getQuestion(controllerForWeb.getGlobalIndex());

    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Tester</title>


<link href="css/my.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
	background-image: url(images/paper_fibers.png);
	background-repeat: repeat;
}
</style>
</head>

<body>
<div style="width: 50%; margin: 0 auto; text-align: center;">

  <div id="question-form"  >

        <h3>Test in progress</h3>

        <fieldset>

            <form  method="post">
<h2><%=currentQuestion.getQuestionText()%></h2>

              <h5>
                <%int variants=currentQuestion.getVariantsList().size();
                        if(variants>1){for(int i=0;i<variants;i++){%>
                <input type="checkbox" name="variant" value="<%=String.valueOf(i)%>"  >
                <%=currentQuestion.getVariantsList().get(i).getVariantText()%> <br>

                <%}}else {%>
                <input type="name" name="variant" > <br>
                <%}%>

                </h5>
                <input type="submit" name="answer" value="Ответить">
                <br >
                <br >
                




                <input class="clearfix"type="submit" name="undo" value="undo" style="{float: left;font-size: 10px;padding: 5px 5px;background: gray;}:hover {background: red}">
                <input class="clearfix"type="submit" name="skip" value="skip" style="{float: left;font-size: 10px;padding: 5px 5px;background: gray;}:hover {background: red}">



            </form>

        </fieldset>

    </div> 

 </div>
 
</body>
</html>

